package com.woohua.security.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/***
 * @title AuthLimitHandler
 * @description
 * @author baiji
 * @version 1.0.0
 * @create 2023/11/23 16:25
 **/
@Slf4j
public class AuthLimitHandler implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
        log.error("用户权限不足,无法访问! 您没有权限访问地址： {}", request.getRequestURI());
        response.sendRedirect("/limit");
    }
}
